<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <person @modify="modify"></person>
    <detail :name="name" :count="count"/>
</div>
</body>
<script src="../../js/vue.js"></script>
<script type="text/javascript">
    Vue.component('person', {
        template: '<div><div>姓名：<input type="text" v-model="name"/></div><div>年龄：<input type="text" v-model="count"/></div><button @click="modify">修改</button></div>',
        data() {
            return {
                name: '句号',
                count: 18
            }
        },
        methods: {
            modify() {
                this.$emit('modify', {name: this.name, count: this.count})
            }
        }
    })
    Vue.component('detail', {
        template: '<div>我是：{{name}}， 我今年 {{count}}岁。</div>',
        props: {
            name: {
                type: String,
                default: '句号'
            },
            count: {
                type: Number,
                default: 18
            }
        },
        methods: {
        }
    })
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                name: '句号',
                count: 18
            }
        },
        methods: {
            modify(detail) {
                this.name = detail.name
                this.count = parseInt(detail.count)
            }
        }
    })
</script>
</html>
